package com.atguigu.seckill.service;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

/**
 * 书写定时任务完成将需要秒杀的信息存入redisz中
 */
@Service
@Slf4j
public class CronSecKillTask {

    @Autowired
    private SecKillService secKillService;

//    @Async
//    @Scheduled(cron = "*/1 * * * * ?")
//    public void test1() throws InterruptedException {
//        System.out.println("测试定时任务");
//        Thread.sleep(3000);
//    }


    /**
     * 查询三天内需要上架的活动--以及对应的商品信息--以及对应商品的详细信息
     * @throws InterruptedException
     */
    @Async
    @Scheduled(cron = "*/10 * * * * ?")
    public void upPro() throws InterruptedException {
        log.info("开始上架");
        secKillService.upSecKillProduct();
    }
}
